<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <button onclick="onClick()">点击存储</button>
    <button onclick="clear()"></button>
    <script>
        const value = sessionStorage.getItem('name');
        console.log(value);
        const name = localStorage.getItem('name1');
        console.log(name);



        function onClick () {
            // window  top
            // setXxx 设置xxx
            // getXxx 得到/取xxx
            sessionStorage.setItem('name', 'hello world');

            localStorage.setItem('name1', 'hello zhangsan');
        }

        function clear () {
            localStorage.removeItem('name1');
            sessionStorage.removeItem('name');
        }

    </script>
</body>
</html>